package com.onlinelibrary.mapper;

import com.onlinelibrary.pojo.Borrow;
import com.onlinelibrary.pojo.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface BorrowMapper {

    @Select("select * from borrow where state!=5 and state!=6")
    List<Borrow> list();

    @Select("select * from borrow where id=#{id}")
    Borrow getBorrow(Borrow borrow);
    Integer createBorrow(Borrow borrow);

    List<Borrow> getBorrows(Borrow borrow);

    @Select("select * from borrow")
    List<Borrow> getAllBorrows(Borrow borrow);

    @Update("update borrow set state=state+1 where id=#{id}")
    Integer checkOk(Borrow borrow);


    Integer deleteBorrow(Borrow borrow);
    @Select("select * from user where id=#{uid}")
    User getUser(Borrow borrow);

    @Select("select count(*) from borrow")
    Integer getBorrowCount();
}
